﻿using MaterialDemo.IService.IPermission;
using MaterialDemo.Model.PowerDTO;
using MaterialDemo.MVC.Filters;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace MaterialDemo.MVC.Controllers
{
    [MySession]
    public class HomeController : Controller
    {
        private readonly ILogger<HomeController> logger;
        private readonly IPowerService powerService;

        public HomeController(ILogger<HomeController> logger, IPowerService powerService)
        {
            this.logger = logger;
            this.powerService = powerService;
        }
        public IActionResult Index()
        {
            ViewBag.name = HttpContext.Session.GetString("UserName");
            //对应角色应有的目录
            List<PowerOutput> menu = powerService.GetMenu(HttpContext.Session.GetString("AllRoleId")).OrderBy(u => u.Name).ToList();


            //进一步构造
            ViewBag.listMenu = menu;
            return View();
        }
        public IActionResult HomeIndex()
        {

            return View();
        }
    }
}
